package com.eclipse.e0112_io.缓存流;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

//BufferedInputStreamDemo
public class Test1 {

public static void main(String[] args) throws IOException { 
	//实例化一个File对象 
	File file = new File("/Users/liuzhuangzhuang/Desktop/io/b.txt");

	//实例化一个缓冲字节输入流的对象
	BufferedInputStream input = new BufferedInputStream(new FileInputStream(file));

/* //读取 byte[] arr = new byte[1024]; int len = 0; while((len = input.read(arr)) != -1) { String string = new String(arr, 0, len); } */

	byte[] arr = new byte[4];
	int len = input.read(arr);
	String string = new String(arr, 0, len);
	System.out.println(string);

	input.mark(66);

	len = input.read(arr);
	string = new String(arr, 0, len); 
	System.out.println(string);

	// 实现了效果：覆水可收 input.reset();

	len = input.read(arr);
	string = new String(arr, 0, len);
	System.out.println(string);

	input.close();

}

}